package net.csdn.business.notify.api.service.impl;

import net.csdn.business.notify.common.model.vo.NotifyResponseVO;
import net.csdn.business.notify.api.service.ISendService;
import net.csdn.business.notify.common.pipeline.ProcessContext;
import net.csdn.business.notify.common.pipeline.ProcessController;
import net.csdn.business.notify.common.pipeline.domain.SendPrivateTaskModel;
import net.csdn.business.notify.common.pipeline.domain.SendTaskModel;
import net.csdn.business.notify.common.pipeline.param.MessageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.Collections;


/**
 * @ClassName SendServiceImpl
 * @Description 发送通知服务相关实现类
 * @Author zhangyl
 * @Date 2023/11/29 13:45
 */
@Service
public class SendServiceImpl implements ISendService {

    @Autowired
    @Qualifier("apiProcessController")
    private ProcessController processController;

    @Override
    public NotifyResponseVO sendRemind(String processType, MessageParam messageParam) {
       /* if (ObjectUtils.isEmpty(processType)) {
            return new SendResponseVO(ProcessStatusEnum.CLIENT_BAD_PARAMETERS.getCode(), ProcessStatusEnum.CLIENT_BAD_PARAMETERS.getMsg(), null);
        }*/
        SendTaskModel remindTaskModel = SendTaskModel.builder()
                .messageParamList(Collections.singletonList(messageParam))
                .build();

        ProcessContext context = ProcessContext.builder()
                .processType(processType)
                .total(1)
                .startTime(System.currentTimeMillis())
                .processModel(remindTaskModel)
                .needBreak(false)
                .response(NotifyResponseVO.success()).build();
        ProcessContext process = processController.process(context);
        return process.getResponse();
    }

    @Override
    public NotifyResponseVO sendPrivate(String processType, MessageParam messageParam) {
       /* if (ObjectUtils.isEmpty(processType)) {
            return new SendResponseVO(ProcessStatusEnum.CLIENT_BAD_PARAMETERS.getCode(), ProcessStatusEnum.CLIENT_BAD_PARAMETERS.getMsg(), null);
        }*/
        SendPrivateTaskModel privateTaskModel = SendPrivateTaskModel.builder()
                .messageParamList(Collections.singletonList(messageParam))
                .build();

        ProcessContext context = ProcessContext.builder()
                .processType(processType)
                .total(1)
                .startTime(System.currentTimeMillis())
                .processModel(privateTaskModel)
                .needBreak(false)
                .response(NotifyResponseVO.success()).build();
        ProcessContext process = processController.process(context);
        return process.getResponse();
    }

}
